package com.shumei.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.shumei.dao.mapper.RecruitMapper;
import com.shumei.dao.pojo.Recruit;
import com.shumei.service.RecruitService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RecruitServiceImpl implements RecruitService {
    @Autowired
    RecruitMapper recruitMapper;
    @Override
    public List<Recruit> selectRecruit() {
        List<Recruit> recruits=recruitMapper.selectList(null);

        return recruits;
    }

    @Override
    public void insertRecruit(Recruit recruit) {
        int i = recruitMapper.insert(recruit);
        if (i > 0) {
            System.out.println("招聘表插入成功");

        } else {
            System.out.println("招聘表插入失败");

        }
    }

    @Override
    public void updateRecruit(Recruit recruit) {
        QueryWrapper<Recruit> wrapper=new QueryWrapper<Recruit>();
        wrapper.eq("id",recruit.getId());

        if (recruitMapper.update(recruit,wrapper)>0){
            System.out.println("修改成功");
        }
        else {
            System.out.println("修改失败");
        }
    }

    @Override
    public void deleteRecruit(int id) {
        int i = recruitMapper.deleteById(id);
        if (i>0) {
            System.out.println("删除成功");
        }else{
            System.out.println("删除失败");
        }
    }
}
